﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Twitterizer;
using System.Net;
using System.IO;

namespace Twillo.Core.Controls
{
    public partial class UserBanner : UserControlBase
    {
        [Category("Twitter")]
        public TwitterUser TwitterUser { get { return _user; } set { _user = value; RefreshControl(); } }

        private TwitterUser _user = null;

        public UserBanner()
        {
            InitializeComponent();
        }

        private void RefreshControl()
        {
            ToolTip tip = new ToolTip();
            tip.SetToolTip(this, "");
            lblScreenName.Text = "";
            lblDescription.Text = "";
            lnkWebSite.Text = "";
            lnkWebSite.Tag = "";
            pbIcon.Image = EmptyImage();
            if (this.DesignMode) { return; }
            if (_user == null) { return; }

            if (!string.IsNullOrEmpty(_user.Website))
            {
                lnkWebSite.Text = _user.Website;
                lnkWebSite.Tag = _user.Website;
            }

            pbVerified.Visible = false;

            if (_user.Verified.HasValue)
            {
                pbVerified.Visible = _user.Verified.Value;
                tip.SetToolTip(pbVerified, "Verified");
            }
            pbIcon.Image = LoadImage(_user.ProfileImageLocation);
            lblScreenName.Text = _user.ScreenName;
            lblDescription.Text = _user.Description;
            tip.SetToolTip(this, _user.Description);
        }

    }
}
